package org.hhchat.leetcode.string;

/**
 * Created this one by HMH on 2017/9/30.
 */
public class code459_easy {
    static class Solution {
        public boolean repeatedSubstringPattern(String str) {
            int l = str.length();
            for(int i=l/2;i>=1;i--) {
                if(l%i==0) {
                    int m = l/i;
                    String subS = str.substring(0,i);
                    StringBuilder sb = new StringBuilder();
                    for(int j=0;j<m;j++) {
                        sb.append(subS);
                    }
                    if(sb.toString().equals(str)) return true;
                }
            }
            return false;
        }
    }
    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(solution.repeatedSubstringPattern("aabaaba"));
    }

}
